<template>
	<view class="team-box">
		<view class="team-info">
			<image src="/static/images/index/category/ptbanner.jpg" class="yui-tg-bg" mode="widthFix"></image>
			
		</view>
		<view class="yui-tuangou-nums">
			我的拼团次数{{account.ptnums}}
		</view>
		<view class="team-list">
			 <view class="item-list-block" v-for="(item, index) in tuanlist" :key="index"> 
				<view class="item-info">
					<view class="item-faces"><image :src="item.pic_cover_small" class="team-avatar"></image></view>
					<view class="item-name">
						<view class="item-name-nick">
							{{item.goods_name}}
							</view>
						<view class="item-name-price">拼团金额:￥{{item.tuangou_money}}</view>
					</view>
					
					<tui-button height="52rpx" :size="24" type="orange" shape="circle" class="tuangou_nums_button" v-if="item.tuangou_nums>0">{{item.tuangou_nums}}次</tui-button>
					<tui-button height="52rpx" :size="24" type="orange" shape="circle" class="tuangou_nums_grey_button" v-else>{{item.tuangou_nums}}次</tui-button>
				</view>
			</view>
		</view>
		<tui-loadmore v-if="loadding" :index="3" type="grey"></tui-loadmore>
		<view v-if="tuanlist==''">
			<tui-no-data :fixed="false" imgUrl="/static/images/nodata/error.png">暂无数据</tui-no-data>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				error: true,
				msg: null,
				tuanlist:'',
				userinfo:'',
				loadding: false,
				count:'',
				account:'',
			}
		},
		onShow() {
			this.tui.haslogin();
			if(this.tui.isLogin()){
				this.init();
			}
			this.userinfo = this.tui.getUserInfoData();
		},
		onPullDownRefresh() {
			this.init();			
		},
		methods: {
           init(){
			   this.loadding=true;
			   let token = this.tui.getToken();
			   let datas={
			   	token: token,
			   };
			   let result=this.tui.request('user','post',datas,1000,1,'','myTuangouNums');
			   Promise.resolve(result).then((value)=>{
			      if(value.code==10000){
			      	this.tuanlist=value.data;
			   	//写入缓存
			      }else{
			      	this.tui.toast(value.message);
			      }
				  this.loadding=false;
			   })
			 
			   let account=this.tui.request('user','post',{token: token},1000,1,'','userAccountInfo');
			   Promise.resolve(account).then((value)=>{
			      if(value.code==10000){
			      	this.account=value.data;
			      }
			   })
		   }

		}
	}
</script>

<style>
	@import '../../static/css/yisyui.css';
	page {
		background-color: #F5F5F5;
	}
	
	.tui-content-box {
		width: 100%;
		padding: 0 30rpx;
		box-sizing: border-box;
		position: relative;
	/* 	top: -72rpx; */
		z-index: 10;
	}
	.team-box{
        position: relative;
	}
	.yui-tuangou-nums{
		background:#e8b123;
		line-height: 80rpx;
		color:#fff;
		font-size: 26rpx;
		text-align: center;
		height:80rpx;
	}
	.team-info{

		width: 100% !important;
	}
	.team-avatar {
		width: 100rpx;
		height: 100rpx;
		border-radius: 4rpx;
	
	}
	.yui-tg-bg{
		width:100%;
	}
	.item-name-price{
		color:#949494;
		font-size: 24rpx;
		margin-top: 10rpx;
	}
	.team-nickname{
		margin-left: 20rpx;
		line-height: 50rpx;
	}
	.team-list{
		margin-top: 20rpx;
		padding: 0 30rpx;
		height:100rpx;
	}
	.tuangou_nums_button{
		width:240rpx !important;
		align-items: center;
		margin-top: 30rpx !important;
		background: linear-gradient(to right, #ffc30c , #ffa10a) !important;
	}
	.tuangou_nums_grey_button{
		width:240rpx !important;
		align-items: center;
		margin-top: 30rpx !important;
		background: #c4c8c4 !important;
	}
	.item-list-block{
		background:#fff;
		padding:10rpx 30rpx;
		border-radius: 10rpx;
		margin-bottom: 20rpx;
		box-shadow: 2rpx 2rpx 1rpx #eeeeee;
	}
	.item-info:last-child{
		border:none
	}
	.item-info{
		display: flex;
		box-sizing: border-box;
	
		border-bottom: 1px solid #f1f1f1;
		padding:20rpx 0;
	}
	.item-faces{margin-right: 20rpx;}
	.item-name{
		font-size: 26rpx;color:#545454;width:100%;
	}
	.item-name-nick{
		font-size: 26rpx;
		font-weight: bold;
		word-break: break-all;
		overflow: hidden;
		width:90%;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 1;
		}
	.item-time{font-size: 20rpx;color:#b5b5b5;
	display: flex;
	box-sizing: border-box;}
    .level_name{border-radius: 17rpx;
	background:#f00;display: block;font-size: 20rpx;color:#fff;text-align: center;
	width:34rpx;height:34rpx;}
</style>
